import myAxios from "@/util/request";

/**
 * 添加模板
 */
export const addTemplate = (data: {
    storeId: string;
    name: string;
    description: string;
}) => {
    return myAxios({
        url: '/param/template/add',
        method: 'POST',
        headers: {
            'token': localStorage.getItem('token')
        },
        data
    });
};

/**
 * 修改模板
 */
export const modifyTemplate = (data: {
    id: string;
    name: string;
    description: string;
}) => {
    return myAxios({
        url: '/param/template/modify',
        method: 'POST',
        headers: {
            'token': localStorage.getItem('token')
        },
        data
    });
};

/**
 * 删除模板
 */
export const delTemplate = (id: number) => {
    return myAxios({
        url: '/param/template/del',
        method: 'GET',
        headers: {
            'token': localStorage.getItem('token')
        },
        params: {
            "id": id
        }
    });
};

/**
 * 绑定参数项
 */
export const bindParam = (data: {
    templateId: number;
    paramValueIdList: Array<number>;
}) => {
    return myAxios({
        url: '/param/template/bind',
        method: 'POST',
        headers: {
            'token': localStorage.getItem('token')
        },
        data
    });
};

/**
 * 查看模板详情
 */
export const detail = (templateId: number) => {
    return myAxios({
        url: '/param/template/detail',
        method: 'GET',
        headers: {
            'token': localStorage.getItem('token')
        },
        params: {
            "templateId": templateId
        }
    });
};

/**
 * 查询门店模板列表
 */
export const getStoreTemplate = (storeId: string, name: string, pageNum: number, pageSize: number) => {
    return myAxios({
        url: '/param/template/getStoreTemplate',
        method: 'GET',
        headers: {
            'token': localStorage.getItem('token')
        },
        params: {
            "storeId": storeId,
            "name": name,
            "pageNum": pageNum,
            "pageSize": pageSize
        }
    });
};
